﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NLog;
using NGinnBPM.Lib.Interfaces.Worklist;
using NGinnBPM.MessageBus;
using NGinnBPM.Lib.Operations.ExternalServices;

namespace NGinnBPM.Services.Worklist
{
    public class HttpWorklistService : IWorkListService
    {
        public string Url { get; set; }
        public string CallbackUrl { get; set; }

        public string CreateWorkItem(CreateWorkItem wi)
        {
            ServiceClient sc = new ServiceClient();
            wi.CallbackUrl = CallbackUrl;
            var ret = sc.CallService<CreateWorkItemResponse>(wi);
            return ret.WorkItemId;
        }

        public void CancelWorkItem(string workItemId, string taskInstanceId)
        {
            ServiceClient sc = new ServiceClient();
            var ret = sc.CallService<CancelWorkItemResponse>(new CancelWorkItem { TaskInstanceId = taskInstanceId, WorkitemId = workItemId });
            
        }

        public void WorkItemCompleted(string workItemId, string taskInstanceId)
        {
            ServiceClient sc = new ServiceClient();
            var ret = sc.CallService<NotifyWorkItemCompletedResponse>(new NotifyWorkItemCompleted { TaskInstanceId = taskInstanceId, WorkitemId = workItemId });
        }
    }
}
